<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2012-1-15
  Time: 12:38:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/inc/taglibs.jsp" %>
<link href="${path}/css/tree.css" rel="stylesheet" type="text/css">
<link href="${path}/css/ztree/zTreeStyle.css" rel="stylesheet" type="text/css">
<c:choose>
    <c:when test="${empty model}">
        <c:set var="action" value="${path }/admin/ticket/add"></c:set>
    </c:when>
    <c:otherwise>
        <c:set var="action" value="${path }/admin/ticket/update"></c:set>
    </c:otherwise>
</c:choose>
<div class="pageContent">
    <form method="post" action="${action}" class="pageForm required-validate"
          onsubmit="return iframeCallback(this, resHandler);">
        <div class="pageFormContent" layoutH="56">
            <table>
                <tr>
                    <td>
                        <label>航空公司：</label>
                    </td>
                    <td>
                        <select id="airlinecompedit" name="airlinecomp">
                            <option value="-1">-请选择--</option>
                        </select>
                        <%--<select class="combox required" name="airlinecomp" ajaxurl="${path}/admin/airLineComp.json" valueField="id" textField="name">
                            <option value="-1">-请选择--</option>
                        </select>--%>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>机场：</label>
                    </td>
                    <td>
                        <select id="airport" name="airport">
                            <option value="-1">-请选择--</option>
                        </select>
                        <%--<select class="combox required" name="airport" ajaxurl="${path}/admin/airPort.json" valueField="id" textField="name">
                             <option value="-1">-请选择--</option>
                        </select>--%>

                    </td>
                </tr>
                <tr>
                    <td>
                        <label>型号：</label>
                    </td>
                    <td>
                        <input name="airlinemodel" type="text" size="40" value="${model.airlinemodel}"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>起飞时间：</label>
                    </td>
                    <td>
                        <input name="takeofftime" type="text" size="40" class="required date" format="yyyy-MM-dd HH:mm"
                               value='<fmt:formatDate value="${model.takeofftime}" pattern="yyyy-MM-dd HH:mm"/>'/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>降落时间：</label>
                    </td>
                    <td>
                        <input name="fallofftime" type="text" size="40" class="date" format="yyyy-MM-dd HH:mm"
                               value="<fmt:formatDate value="${model.fallofftime}" pattern="yyyy-MM-dd HH:mm"/>"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>起飞地：</label>
                    </td>
                    <td>
                        <input name="fromareaName" id="fromareaName" type="text" value="${model.fromareaName}"/>
                        <input name="fromarea" id="fromarea" type="hidden" value="${model.fromarea}"/>
                        <a id="fromBtn" href="javascript:void(0)" onclick="showFromMenu()">选择</a>
                    </td>
                </tr>
                <tr>
                    <td>

                    </td>
                    <td>
                        <div id="fromMenuContent" class="menuContent" style="display:none;">
                            <ul id="treeFrom" class="ztree" style="margin-top:0; width:160px;"></ul>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>目的地：</label>
                    </td>
                    <td>
                        <input name="desareaName" id="desareaName" type="text" value="${model.desareaName}"/>
                        <input name="desarea" id="desarea" type="hidden" value="${model.desarea}"/>
                        <a id="desBtn" href="javascript:void(0)" onclick="showDesMenu();">选择</a>
                    </td>
                </tr>
                <tr>
                    <td>

                    </td>
                    <td>
                        <div id="desMenuContent" class="menuContent" style="clear:both;display:none;">
                            <ul id="treeDes" class="ztree" style="margin-top:0; width:160px;"></ul>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>价格：</label>
                    </td>
                    <td>
                        <input name="price" type="text" size="40" value="${model.price}"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>数量：</label>
                    </td>
                    <td>
                        <input name="totalcount" type="text" size="40" value="${model.totalcount}"/>
                    </td>
                </tr>

                <c:if test="${!empty model}">
                    <tr>
                        <td>

                            <input type="hidden" name="id" value="${model.id}">
                        </td>
                    </tr>
                </c:if>


            </table>


        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit">保存</button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">取消</button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>
<script type="text/javascript" src="${path}/js/ztree/jquery.ztree.core-3.0.js"></script>
<script type="text/javascript" src="${path}/js/admin/ticket.js"></script>
<script type="text/javascript">
    /**
     *起飞地区树参数1.
     */
    var setting1 = {
        async: {
            enable: true,
            url:"${path}/admin/area/nodes.json",
            autoParam:["id", "name=n", "level=lv"],
            otherParam:{"otherParam":"zTreeAsyncTest"}
            //dataFilter: filter
        },
        callback:{
            onClick: fromOnClick
        }
    };
    /**
     *目的地区树参数2.
     */
    var setting2 = {
        async: {
            enable: true,
            url:"${path}/admin/area/nodes.json",
            autoParam:["id", "name=n", "level=lv"],
            otherParam:{"otherParam":"zTreeAsyncTest"}
            //dataFilter: filter
        },
        callback:{
            onClick: desOnClick
        }
    };
    /**
     * 起飞地树点击.
     * @param e
     * @param treeId
     * @param treeNode
     */
    function fromOnClick(e, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj(treeId);
        nodes = zTree.getSelectedNodes();
        if (nodes.length > 1) {
            alert("只能选择一个地区");
        }
        v = nodes[0].name;
        i = nodes[0].id;
        $("#fromareaName").attr("value", v);
        $("#fromarea").attr("value", i);
        $("#fromMenuContent").toggle("fast");
    }
    /**
     * 目的地树点击.
     * @param e
     * @param treeId
     * @param treeNode
     */
    function desOnClick(e, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj(treeId);
        nodes = zTree.getSelectedNodes();
        if (nodes.length > 1) {
            alert("只能选择一个地区");
        }
        v = nodes[0].name;
        i = nodes[0].id;
        $("#desareaName").attr("value", v);
        $("#desarea").attr("value", i);
        $("#desMenuContent").toggle("fast");
    }
     /**
     * 起飞地选择.
     */
    function showFromMenu() {
        $("#fromMenuContent").toggle("fast");
    }
    /**
     * 目的地选择.
     */
    function showDesMenu() {
        $("#desMenuContent").toggle("fast");
    }

    $(document).ready(function(){
        $.fn.zTree.init($("#treeFrom"), setting1);
        $.fn.zTree.init($("#treeDes"), setting2);
        var props = {
            basePath:'${path}',
            modelAirLineComp:'${model.airlinecomp}',
            modelAirPort:'${model.airport}'
        }
        var t = new ticket(props);
        t.rendAirLineCompEdit();
        t.rendAirPort();
    });
    function resHandler(response) {
        alertMsg.correct('您的数据提交成功！');
        navTab.reload("${path}/admin/ticket", "");
        $.pdialog.closeCurrent();
    }
</script>


